package com.example.swaggerDemo.controller.filter;

import com.example.swaggerDemo.controller.filter.LoginHandlerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.Arrays;
import java.util.List;

@Configuration
public class WebSecurityConfig extends WebMvcConfigurerAdapter {


    public LoginHandlerInterceptor getSecurityInterceptor() {
        return new LoginHandlerInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration addInterceptor = registry.addInterceptor(getSecurityInterceptor());
        // 排除配置--对下面的不进行拦截
        addInterceptor.excludePathPatterns("/wxAuth/wxlogin");
        addInterceptor.excludePathPatterns("/wxAuth/wxcallBack");

        // 拦截配置
        addInterceptor.addPathPatterns("/Article/findAll");
        addInterceptor.addPathPatterns("/Article/findid");

    }
}